//
//  ECUIView_PayFooter.m
//  Edu_iOS2018
//
//  Created by yanyan on 2018/1/22.
//  Copyright © 2018年 yanyan. All rights reserved.
//

#import "ECUIView_PayFooter.h"
#import "CourseModel.h"
@interface ECUIView_PayFooter()
@property(nonatomic,strong)UILabel *priceLabel;//支付价格显示
@property (nonatomic,strong)UIButton *submitBtn;//学习按钮，学习，购买统一
@end
@implementation ECUIView_PayFooter
- (void)addSubviews
{
    [super addSubviews];
//    self.userInteractionEnabled = YES;
    [self addSubview:self.priceLabel];

    _submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    _submitBtn.frame = self.bounds;
    [_submitBtn setBackgroundImage:[UIImage imageNamed:@"detail_studybg"] forState:UIControlStateNormal];
    _submitBtn.showsTouchWhenHighlighted = YES;
    [_submitBtn setTitle:@"提交订单" forState:UIControlStateNormal];
    [_submitBtn addTarget:self action:@selector(action_study:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_submitBtn];
    [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self);
        make.top.equalTo(self);
        make.width.equalTo(self).multipliedBy(0.4);
        make.height.equalTo(@(TABBAR_FOOTER_HEIGHT));
   }];
    [_submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_priceLabel.mas_right);
        make.top.equalTo(self);
        make.width.equalTo(self).multipliedBy(0.60);
        make.height.equalTo(@(TABBAR_FOOTER_HEIGHT));
        make.right.equalTo(self.mas_right);
    }];
//
}
- (UILabel *)priceLabel{
if (!_priceLabel) {
        _priceLabel = [[UILabel alloc]init];
        _priceLabel.font = [UIFont systemFontOfSize:17 * kPercentage];
        _priceLabel.textAlignment = NSTextAlignmentCenter;
//        [_priceLabel setAttributedText:[ECFormatHelper attributedStringForPromotionPrice:@"299.09" decimal:2]];
        _priceLabel.textColor = [UIColor colorWithHexString:@"#ef4023"];
    }
return _priceLabel;
}
- (void)setObject:(id)object
{
    [super setObject:object];
    CourseModel *mo = object;
    self.priceLabel.attributedText = [ECFormatHelper attributedStringForPromotionPrice:mo.price decimal:2];
}
- (void)action_study:(id)sender{
    if (self.block_selected) {
        self.block_selected(sender);
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
